package Synchronized;

public class demo3 {

        public static void main(String[] args) throws InterruptedException {
            Object locker = new Object();
            Thread t1 = new Thread(()->{
                synchronized (locker)
                {
                    System.out.println(Thread.currentThread().getName()+"抢到锁进行加锁....");
                }
            },"线程1");
            Thread t2 = new Thread(()->{
                synchronized (locker)
                {
                    System.out.println(Thread.currentThread().getName()+"抢到锁进行加锁....");
                }
            },"线程2");
          Thread t3 = new Thread(()->{
                synchronized (locker)
                {
                    System.out.println(Thread.currentThread().getName()+"抢到锁进行加锁....");
                }
            },"线程3");
            t1.start();
            t2.start();
            t3.start();
        }
    }


